import 'dart:convert';

import 'package:bruno/bruno.dart';
import 'package:dio/dio.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sph_driver/Main/FleetManagement/AddTrailerCardView.dart';
import 'package:sph_driver/Main/FleetManagement/AddVehicleView.dart';
import 'package:sph_driver/Main/FleetManagement/FleetDetails.dart';
import 'package:sph_driver/Main/FleetManagement/FleetInformationView.dart';
import 'package:sph_driver/Main/FleetManagement/QueryViolations.dart';

import '../../AppConfig/Config.dart';
import '../../AppConfig/LocalStorage.dart';
import '../../AppConfig/RouteAct.dart';
import '../../Message/MessageCenter.dart';
import '../../Order/WaybillDetails/UnconfirmedTransportationAgreement.dart';
import '../../Order/WaybillDetails/WaybillDetailsView.dart';
import '../../http/NoLoadingGetApi.dart';
import '../../http/api.dart';
import '../../l10n/messages.dart';
import 'InvitingDrivers.dart';

class MyFleet extends StatefulWidget {
  const MyFleet({super.key, required this.captainId});
  final String captainId;
  @override
  State<MyFleet> createState() => _MyFleetState();
}

class _MyFleetState extends State<MyFleet> {

  int isCheck=0;
  List carNumberList=["苏E12345","苏B22222"];
  List driverNameList=["张大帅","张二帅"];
  List orderList =["张大帅","张二帅"];
  Map fleetData={};
  List  carListdata=[];
  List fleetDriverList=[];
  List fleetOrderList=[];
  int pageNum=1;
  String driverId='';
  FocusNode focusNode = FocusNode();
  BrnSearchTextController scontroller = BrnSearchTextController();
  TextEditingController textController = TextEditingController();
  @override
  void initState() {
    textController.addListener(() {
      if (focusNode.hasFocus) {
        if (!BrunoTools.isEmpty(textController.text)) {
          scontroller.isClearShow = true;
          scontroller.isActionShow = true;
        }
      }
    });
    focusNode.addListener(() {
      if (focusNode.hasFocus) {
        if (!BrunoTools.isEmpty(textController.text)) {
          scontroller.isClearShow = true;
        }
      }
    });
    getFleetMessage();
    getFleetVehicles();
    super.initState();
  }

  Future<void> getFleetMessage() async {
    driverId=(await UserIdManager.getUserID())!;
    NoLoadinggetApiManager.getData(
      context,
      "api/auth/driver/fleet/getByDriverId",
      {'driverId':widget.captainId,},
          (responseData)  {
        setState(() {

          fleetData=responseData['data'];
        });

      },
    );
  }
  void getFleetVehicles(){
    NoLoadinggetApiManager.getData(
      context,
      "api/auth/driver/fleet/user/vehiclePage",
      {'current':pageNum,"size":20,"captainId":widget.captainId},
          (responseData)  {
        setState(() {
          if(pageNum==1){
            carListdata=responseData['data']['records'];
          }else{
            if(responseData['data']['records'].isNotEmpty){
              carListdata.addAll(responseData['data']['records']);
            }else{
              pageNum=pageNum-1;
            }

          }

        });

      },
    );
  }

//获取车队成员列表
  void getFleetDriversAction(){
    NoLoadinggetApiManager.getData(
      context,
      "api/auth/driver/fleet/user/driverPage",
      {'current':pageNum,"size":20,"captainId":widget.captainId},
          (responseData)  {
        setState(() {
          if(pageNum==1){
            fleetDriverList=responseData['data']['records'];
          }else{
            if(responseData['data']['records'].isNotEmpty){
              fleetDriverList.addAll(responseData['data']['records']);
            }else{
              pageNum=pageNum-1;
            }

          }

        });

      },
    );
  }
  //获取车队运单列表
  void getFleetOrdersAction()async{
    NoLoadinggetApiManager.getData(
      context,
      "api/waybill/driver/waybill/page",
      {'current':pageNum,"size":20,"captainId":widget.captainId,"mode":widget.captainId!=driverId?"CAPTAIN":""},
          (responseData)  {
        setState(() {
          if(pageNum==1){
            fleetOrderList=responseData['data']['records'];
          }else{
            if(responseData['data']['records'].isNotEmpty){
              fleetOrderList.addAll(responseData['data']['records']);
            }else{
              pageNum=pageNum-1;
            }

          }

        });

      },
    );
  }
  Future _onRefresh() async {
    if(isCheck==0) {
      pageNum=1;
      getFleetVehicles();
    }
    if(isCheck==1) {
      pageNum=1;
      getFleetDriversAction();
    }
    if(isCheck==2){
      pageNum=1;
      getFleetOrdersAction();
    }
  }
  Future<void> _loadMoreData() async {
    if (isCheck == 0&&carListdata.length > 20*pageNum){
      pageNum=pageNum+1;
      getFleetVehicles();
    }else if (isCheck == 1&&fleetDriverList.length > 20*pageNum){
      pageNum=pageNum+1;
      getFleetDriversAction();
    }else if (isCheck == 2&&fleetOrderList.length > 20*pageNum){
      pageNum=pageNum+1;
      getFleetOrdersAction();
    }

  }
  void unbindDriverAct(String driverId){
    NoLoadinggetApiManager.getData(
      context,
      "api/auth/driver/fleet/user/unbind",
      {'driverId':driverId,},
          (responseData)  {
        setState(() {
          getFleetDriversAction();

        });

      },
    );
  }
  void deleDriverAct(String driverId){
    NoLoadinggetApiManager.getData(
      context,
      "api/auth/driver/fleet/user/delete",
      {'driverId':driverId,},
          (responseData)  {
        setState(() {
          getFleetDriversAction();
        });

      },
    );
  }
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    var messages = AppLocalizations.of(context)!;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        backgroundColor: Colors.white,
        centerTitle: true,
        title: Text(messages['我的车队'],style: TextStyle(color: Colors.black,fontWeight: FontWeight.w300,fontSize: 16.sp ),),
        leading: IconButton(
          icon: Icon(Icons.arrow_back_ios, color: Colors.black),
          onPressed: () => Navigator.of(context).pop(),
        ),
        actions: [
          TextButton(onPressed: (){
            Navigator.push( context, FadeRoute(page:MessageCenter()));
          }, child: Text(messages['消息'],style: TextStyle(color: Colors.black,fontSize: 14.sp),)),
        ],
      ),
      body:fleetData.isEmpty?SizedBox(): Column(
    children: [
    Expanded(
      child:ListView(
      children: [
        GestureDetector(
          child:   Container(
            margin: EdgeInsets.only(top: 8.h,right: 10.w,left: 10.w),
            padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h,bottom: 8.h),
            decoration: BoxDecoration(
                color:Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    Container(
                      width: 60.w,
                      height: 60.h,
                      child:  fleetData['avatarPath']!=null&&fleetData['avatarPath']!=""?
                      CircleAvatar(
                        radius: 15,
                        backgroundImage: NetworkImage(MyServiceUrl.imgHeader +fleetData['avatarPath']),
                      )
                          :  CircleAvatar(
                        radius: 15,
                        backgroundImage: AssetImage("lib/Images/login/默认头像.jpeg"),
                      ),
                    ),
                    SizedBox(width: 8.w,),
                     Text(fleetData['name'],style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600,fontSize: 14.sp),),
                  ],
                ),
                Icon(Icons.arrow_forward_ios,color: MyColors.hintColor,),
              ],
            ),
          ),
          onTap: ()async{
           final result=await Navigator.push( context, FadeRoute(page:FleetDetails(fleetMap: fleetData, captainId:widget.captainId,)));
           if(result!=null){
             getFleetMessage();
           }
          },
        ),
        SizedBox(height: 8.h,),
        Container(
          margin: EdgeInsets.only(left: 10.w,right: 10.w),
          decoration: BoxDecoration(
              color:Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(10))),
          child:     Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Column(
                children: [
                  TextButton(onPressed: (){
                    setState(() {
                      isCheck=0;
                      pageNum=1;
                      getFleetVehicles();
                    });
                  },
                    child:  Row(
                      children: [
                        Text("车辆管理",style: TextStyle (fontWeight:isCheck==0? FontWeight.w600:FontWeight.w300,color:Colors.black,fontSize: isCheck==0?14.sp:12.sp),),
                      ],
                    ),
                  ),
                  Container(height: 2.h,width: 27.w,color:isCheck==0?Color.fromRGBO(231, 112, 27, 0.85) : Colors.white,),
                ],
              ),
              Column(
                children: [
                  TextButton(onPressed: (){
                    setState(() {
                      isCheck=1;
                      pageNum=1;
                      getFleetDriversAction();
                    });
                  },
                    child:  Row(
                      children: [
                        Text("司机管理",style: TextStyle (fontWeight:isCheck==1? FontWeight.w600:FontWeight.w300,color:Colors.black,fontSize: isCheck==1?14.sp:12.sp),),
                      ],
                    ),
                  ),
                  Container(height: 2.h,width: 27.w,color:isCheck==1?Color.fromRGBO(231, 112, 27, 0.85) : Colors.white,),
                ],
              ),
              Column(
                children: [
                  TextButton(onPressed: (){
                    setState(() {

                      isCheck=2;
                      pageNum=1;
                      getFleetOrdersAction();
                    });
                  },
                    child:  Row(
                      children: [
                        Text("车队运单",style: TextStyle (fontWeight:isCheck==2? FontWeight.w600:FontWeight.w300,color:Colors.black,fontSize: isCheck==2?14.sp:12.sp),),
                      ],
                    ),
                  ),
                  Container(height: 1.h,width: 27.w,color:isCheck==2?Color.fromRGBO(231, 112, 27, 0.85) : Colors.white,),
                ],
              ),
            ],
          ),
        ),

          Container(
            margin: EdgeInsets.only(top: 1.h,right: 10.w,left: 10.w),
            // padding: EdgeInsets.only(top: 8.h,bottom: 8.h),
            decoration: BoxDecoration(
              color:Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(10)),),
            child: Column(
              children: [

                isCheck==0&&carListdata.length>0?
                EasyRefresh(
                  header:
                  ClassicHeader(
                    dragText: '下拉刷新',
                    armedText: '准备释放',
                    readyText: '加载中...',
                    processingText: '加载中...',
                    processedText: '刷新成功',
                    noMoreText: '暂无更多',
                    failedText: '刷新失败',
                    messageText: '刷新时间 %T',
                  ),

                  footer: ClassicFooter(
                    dragText: '加载更多',
                    armedText: '准备释放',
                    readyText: '加载中...',
                    processingText: '加载中...',
                    processedText: '加载成功',
                    noMoreText: '暂无更多',
                    failedText: '加载失败',
                    messageText: '加载时间 %T',
                  ),
                  onRefresh: _onRefresh,
                  onLoad: carListdata.length > 20*pageNum-1?_loadMoreData:null,
                  child:
                Container(
                  // margin: EdgeInsets.only(top: 8.h),
                 color: MyColors.backgreyColor,
                 height: widget.captainId==driverId?screenSize.height-300.h:screenSize.height-230.h,
                  child: ListView.builder(
                      itemCount: carListdata.length,
                      itemBuilder: (BuildContext context, int index) {
                        return  Container(
                          padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.h),
                          decoration: BoxDecoration(
                            color:Colors.white,
                            borderRadius: BorderRadius.all(Radius.circular(10)),),
                          child: Column(
                            children: [
                              Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  Column(
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: [
                                      Row(
                                        children: [
                                          Text(carListdata[index]['vehicleNum'],style:TextStyle(color: Colors.black,fontSize: 13.sp) ,),
                                          SizedBox(width: 8.w,),
                                        ],
                                      ),
                                      SizedBox(height: 2.h,),
                                      Text(carListdata[index]['vehicleModel'].toString()+"/"+carListdata[index]['vehicleLength'].toString()+"米",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                                    ],
                                  ),
                                  if(widget.captainId==driverId)
                                  GestureDetector(
                                    child:     Row(
                                      children: [
                                        Text("编辑",style: TextStyle(fontSize: 16.sp,color: MyColors.themeColor),),
                                        Icon(Icons.arrow_forward_ios,color: MyColors.hintColor,),
                                      ],
                                    ),
                                    onTap: ()async{
                                      final result=await Navigator.push( context, FadeRoute(page:FleetInformationView(fleetMap: fleetData, id:carListdata[index]['vehicleId'] ,)));
                                      if(result=="success"){

                                      }
                                    },
                                  ),

                                ],
                              ),
                              SizedBox(height: 2.h,),
                              Row(
                                children: [
                                  Text("行驶证",style: TextStyle(fontSize: 10.sp,color: MyColors.authTipColor,),),
                              (carListdata[index]['vehicleDrivingLicenseStatus']==0||carListdata[index]['vehicleDrivingLicenseStatus']==3)?

                                  Icon(Icons.
                                  error_outline,color: Colors.red,size: 12,)
                               :carListdata[index]['vehicleDrivingLicenseStatus']==1?

                              Icon(Icons.access_time,color: MyColors.themeColor,size: 12,)
                               :
                              Icon(Icons.check_circle_outline,color: Colors.green,size: 12,),

                                  SizedBox(width: 8.w,),
                                  Text("道路运输证",style: TextStyle(fontSize: 10.sp,color: MyColors.authTipColor,),),
                                  (carListdata[index]['roadTransportCertificateStatus']==0||carListdata[index]['roadTransportCertificateStatus']==3)?

                                  Icon(Icons.
                                  error_outline,color: Colors.red,size: 12,)
                                      :carListdata[index]['roadTransportCertificateStatus']==1?

                                  Icon(Icons.access_time,color: MyColors.themeColor,size: 12,)
                                      :
                                  Icon(Icons.check_circle_outline,color: Colors.green,size: 12,),


                                ],
                              ),
                              SizedBox(height: 8.h,),
                              if(widget.captainId==driverId)
                              Container(
                                padding: EdgeInsets.only(left: 10.w,right: 10.w),
                                height: 1,
                                color: MyColors.backgreyColor,
                              ),
                              if(widget.captainId==driverId)
                              SizedBox(height: 8.h,),
                              if(widget.captainId==driverId)
                              Row(
                                children: [
                                  if(widget.captainId==driverId)
                                  GestureDetector(
                                    child: Container(
                                      decoration: BoxDecoration(
                                          border: Border.all(
                                            color: MyColors.themeColor, // Set the color of the border
                                            width: 1.0.w, // Set the width of the border
                                          ),
                                          color:Colors.white,
                                          borderRadius: BorderRadius.all(Radius.circular(30))),
                                      child:Center(
                                      child:   Text((carListdata[index]['type']==0)?"删除":"解绑",style: TextStyle(fontSize: 12.sp,color: MyColors.themeColor),),
                                      ),
                                      width: 76.w,
                                      height: 25.h,
                                    ),
                                    onTap: (){
                                     if (carListdata[index]['type']==0){
                                       deleDriverAct(carListdata[index]['driverId']);
                                     }else{
                                       unbindDriverAct(carListdata[index]['driverId']);
                                     }

                                    },
                                  ),
                                  SizedBox(width: 8.w,),
                                  GestureDetector(
                                    child: Container(
                                      decoration: BoxDecoration(
                                          color:MyColors.themeColor,
                                          borderRadius: BorderRadius.all(Radius.circular(30))),

                                      child:Center(
                                      child: Text("查看定位",style: TextStyle(fontSize: 12.sp,color: Colors.white),),
                                       ),
                                     width: 76.w,
                                      height: 25.h,
                                    ),
                                    onTap: (){

                                    },
                                  ),
                                ],
                                mainAxisAlignment: MainAxisAlignment.end,
                              ),
                              if(widget.captainId==driverId)
                              SizedBox(height: 10.h,),

                              Container(
                                padding: EdgeInsets.only(left: 10.w,right: 10.w),
                                height: 1,
                                color: MyColors.backgreyColor,
                              ),

                            ],
                          ),


                        );

                      }
                  ) ,

                )):isCheck==1?
                EasyRefresh(
                    header:
                    ClassicHeader(
                      dragText: '下拉刷新',
                      armedText: '准备释放',
                      readyText: '加载中...',
                      processingText: '加载中...',
                      processedText: '刷新成功',
                      noMoreText: '暂无更多',
                      failedText: '刷新失败',
                      messageText: '刷新时间 %T',
                    ),

                    footer: ClassicFooter(
                      dragText: '加载更多',
                      armedText: '准备释放',
                      readyText: '加载中...',
                      processingText: '加载中...',
                      processedText: '加载成功',
                      noMoreText: '暂无更多',
                      failedText: '加载失败',
                      messageText: '加载时间 %T',
                    ),
                    onRefresh: _onRefresh,
                    onLoad: carListdata.length>19?_loadMoreData:null,
                    child:
                Container(
                  color: MyColors.backgreyColor,
                  height:  widget.captainId==driverId?screenSize.height-300.h:screenSize.height-230.h,
                  child: ListView.builder(
                      itemCount: fleetDriverList.length,
                      itemBuilder: (BuildContext context, int index) {
                        return Container(
                          padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
                          decoration: BoxDecoration(
                            color:Colors.white,
                            borderRadius: BorderRadius.all(Radius.circular(10)),),
                          child:   Column(
                            children: [
                              Row(
                                children: [
                                  Container(
                                    width: 45.w,
                                    height: 45.h,
                                    child:  fleetDriverList[index]['avatarPath']!=null&&fleetDriverList[index]['avatarPath']!=""?
                                    CircleAvatar(
                                      radius: 15,
                                      backgroundImage: NetworkImage(MyServiceUrl.imgHeader +fleetData['avatarPath']),
                                    )
                                        :  CircleAvatar(
                                      radius: 15,
                                      backgroundImage: AssetImage("lib/Images/login/默认头像.jpeg"),
                                    ),
                                  ),
                                  SizedBox(width: 8.w,),
                                  Column(
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: [
                                      Row(
                                        children: [
                                          Text(fleetDriverList[index]['realName'],style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                                          SizedBox(width: 8.w,),

                                        ],
                                      ),
                                      Text(fleetDriverList[index]['phoneNum'],style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                                      Row(
                                        children: [
                                          Text("身份认证",style: TextStyle(fontSize: 10.sp,color: MyColors.authTipColor,),),
                                          (fleetDriverList[index]['personalStatus']==0||fleetDriverList[index]['personalStatus']==3)?

                                          Icon(Icons.error_outline,color: Colors.red,size: 12,)
                                              :fleetDriverList[index]['personalStatus']==1?

                                          Icon(Icons.access_time,color: MyColors.themeColor,size: 12,)
                                              :
                                          Icon(Icons.check_circle_outline,color: Colors.green,size: 12,),

                                          SizedBox(width: 8.w,),
                                          Text("驾驶证",style: TextStyle(fontSize: 10.sp,color: MyColors.authTipColor,),),
                                          (fleetDriverList[index]['driverLicenseStatus']==0||fleetDriverList[index]['driverLicenseStatusdriverLicenseStatus']==3)?
                                          Icon(Icons.
                                          error_outline,color: Colors.red,size: 12,)
                                              :fleetDriverList[index]['driverLicenseStatus']==1?

                                          Icon(Icons.access_time,color: MyColors.themeColor,size: 12,)
                                              :
                                          Icon(Icons.check_circle_outline,color: Colors.green,size: 12,),

                                          SizedBox(width: 8.w,),
                                          Text("从业资格证",style: TextStyle(fontSize: 10.sp,color: MyColors.authTipColor,),),
                                          (fleetDriverList[index]['qualificationCertificateStatus']==0||fleetDriverList[index]['qualificationCertificateStatus']==3)?

                                          Icon(Icons.
                                          error_outline,color: Colors.red,size: 12,)
                                              :fleetDriverList[index]['qualificationCertificateStatus']==1?
                                          Icon(Icons.access_time,color: MyColors.themeColor,size: 12,)
                                              :
                                          Icon(Icons.check_circle_outline,color: Colors.green,size: 12,),

                                        ],
                                      ),
                                    ],
                                  ),
                                ],
                              ),
                              SizedBox(height: 10.h,),
                              Container(
                                padding: EdgeInsets.only(left: 10.w,right: 10.w),
                                height: 1,
                                color: MyColors.backgreyColor,
                              ),
                            ],
                          ),
                        );



                      }
                  ),
                )):
                    Column(
                      children: [

                        // BrnSearchText(
                        //   focusNode: focusNode,
                        //   controller: textController,
                        //   searchController: scontroller..isActionShow = false,
                        //
                        //   innerColor:MyColors.backgreyColor,
                        //   borderRadius:BorderRadius.all(const Radius.circular(30.0)),
                        //   hintText:"输入手机号搜索",
                        //   onTextClear: () {
                        //     debugPrint('sss');
                        //     return false;
                        //   },
                        //   // autoFocus: true,
                        //   onActionTap: () {
                        //     scontroller.isClearShow = false;
                        //     scontroller.isActionShow = false;
                        //     focusNode.unfocus();
                        //     BrnToast.show('取消', context);
                        //   },
                        //   onTextCommit: (text) {
                        //     BrnToast.show('提交内容 : $text', context);
                        //   },
                        //   onTextChange: (text) {
                        //     BrnToast.show('输入内容 : $text', context);
                        //   },
                        // ),

                      ],
                    ),

              ],

            ),
          ),
        isCheck==2&&orderList.length==0?
        Container(
            child: Center(
              child: Column(
                children: [
                  SizedBox(height: 40.h,),
                  Image.asset("lib/Images/PersonCenter/我的车队空白页状态.png",height: 212.h,width: 212.w,),
                  Text("您还没有车队运单哦～",style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
                ],
              ),
            )
        ):
        SizedBox(height: 10.h,),
              isCheck==2?
              EasyRefresh(
                  header:
                  ClassicHeader(
                    dragText: '下拉刷新',
                    armedText: '准备释放',
                    readyText: '加载中...',
                    processingText: '加载中...',
                    processedText: '刷新成功',
                    noMoreText: '暂无更多',
                    failedText: '刷新失败',
                    messageText: '刷新时间 %T',
                  ),

                  footer: ClassicFooter(
                    dragText: '加载更多',
                    armedText: '准备释放',
                    readyText: '加载中...',
                    processingText: '加载中...',
                    processedText: '加载成功',
                    noMoreText: '暂无更多',
                    failedText: '加载失败',
                    messageText: '加载时间 %T',
                  ),
                  onRefresh: _onRefresh,
                  onLoad: fleetOrderList.length>19?_loadMoreData:null,
                  child:
                  Container(
                    height:screenSize.height-300.h,
                    child:ListView.separated(

                      shrinkWrap:true,
                      itemCount: fleetOrderList.length,
                      itemBuilder: (BuildContext context, int index) {

                        return  GestureDetector(
                          child: Container(

                            margin: EdgeInsets.only(left: 8.w,right: 8.w),
                            padding: EdgeInsets.only(bottom: 11.h,right: 9.w),
                            decoration: BoxDecoration(
                                color: Colors.white,
                                borderRadius: BorderRadius.all(Radius.circular(10))),
                            child:Column(
                              children: [
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Row(
                                      children: [
                                        if(fleetOrderList[index]['cancelStatus']==1)
                                          BrnTagCustom(
                                            tagText:'已取消',
                                            backgroundColor: Color.fromRGBO(154, 154, 154, 0.5),
                                            textPadding:EdgeInsets.only(left: 8.w,right: 8.w,top: 2.h,bottom: 2.h),
                                            fontSize: 12.sp,
                                            tagBorderRadius: BorderRadius.only(topLeft: Radius.circular(10),bottomRight: Radius.circular(10) ),
                                          ),
                                        if(fleetOrderList[index]['deliveryStatus']==1)
                                          BrnTagCustom(
                                            tagText:'已完成',
                                            backgroundColor: Color.fromRGBO(154, 154, 154, 0.5),
                                            textPadding:EdgeInsets.only(left: 8.w,right: 8.w,top: 2.h,bottom: 2.h),
                                            fontSize: 12.sp,
                                            tagBorderRadius: BorderRadius.only(topLeft: Radius.circular(10),bottomRight: Radius.circular(10) ),
                                          ),
                                        if( fleetOrderList[index]['contractStatus']==0&&fleetOrderList[index]['cancelStatus']!=1&&fleetOrderList[index]['deliveryStatus']!=1)
                                          BrnTagCustom(
                                            tagText:fleetOrderList[index]['mode']=="DRIVER"?"待货主确认":"指派待确认",
                                            backgroundColor: Color.fromRGBO(7, 171, 111, 0.5),
                                            textPadding:EdgeInsets.only(left: 8.w,right: 8.w,top: 2.h,bottom: 2.h),
                                            fontSize: 12.sp,
                                            tagBorderRadius: BorderRadius.only(topLeft: Radius.circular(10),bottomRight: Radius.circular(10) ),
                                          ),
                                        if( fleetOrderList[index]['contractStatus']==2&&fleetOrderList[index]['cancelStatus']!=1&&fleetOrderList[index]['deliveryStatus']!=1)
                                          BrnTagCustom(
                                            tagText:fleetOrderList[index]['contractMode']=="DRIVER"?"货主待确认":"司机待确认",
                                            backgroundColor: Color.fromRGBO(7, 171, 111, 0.5),
                                            textPadding:EdgeInsets.only(left: 8.w,right: 8.w,top: 2.h,bottom: 2.h),
                                            fontSize: 12.sp,
                                            tagBorderRadius: BorderRadius.only(topLeft: Radius.circular(10),bottomRight: Radius.circular(10) ),
                                          ),
                                        if(fleetOrderList[index]['contractStatus']==1&&fleetOrderList[index]['driverStatus']==0&&fleetOrderList[index]['deliveryStatus']==0&&fleetOrderList[index]['cancelStatus']!=1)
                                          BrnTagCustom(
                                            tagText:'确认已装货',
                                            backgroundColor: Color.fromRGBO(154, 154, 154, 0.5),
                                            textPadding:EdgeInsets.only(left: 8.w,right: 8.w,top: 2.h,bottom: 2.h),
                                            fontSize: 12.sp,
                                            tagBorderRadius: BorderRadius.only(topLeft: Radius.circular(10),bottomRight: Radius.circular(10) ),
                                          ),
                                        if(fleetOrderList[index]['contractStatus']==1&&fleetOrderList[index]['driverStatus']==1&&fleetOrderList[index]['deliveryStatus']==0&&fleetOrderList[index]['contractStatus']!=2&&fleetOrderList[index]['cancelStatus']!=1)
                                          BrnTagCustom(
                                            tagText:'确认已卸货',
                                            backgroundColor: Color.fromRGBO(154, 154, 154, 0.5),
                                            textPadding:EdgeInsets.only(left: 8.w,right: 8.w,top: 2.h,bottom: 2.h),
                                            fontSize: 12.sp,
                                            tagBorderRadius: BorderRadius.only(topLeft: Radius.circular(10),bottomRight: Radius.circular(10) ),
                                          ),

                                        if(fleetOrderList[index]['deliveryStatus']==0&&fleetOrderList[index]['driverStatus']==2&&fleetOrderList[index]['contractStatus']!=2&&fleetOrderList[index]['cancelStatus']!=1)
                                          BrnTagCustom(
                                            tagText:'待货主完成',
                                            backgroundColor: Color.fromRGBO(154, 154, 154, 0.5),
                                            textPadding:EdgeInsets.only(left: 8.w,right: 8.w,top: 2.h,bottom: 2.h),
                                            fontSize: 12.sp,
                                            tagBorderRadius: BorderRadius.only(topLeft: Radius.circular(10),bottomRight: Radius.circular(10) ),
                                          ),

                                        SizedBox(width:8.w,),
                                        if(fleetOrderList[index]['companyId']!="0")
                                          Image.asset("lib/Images/OrderList/企业标签.png",width: 30.w,height: 18.h,),
                                        if(fleetOrderList[index]['invoiceType']==1)
                                          Image.asset("lib/Images/OrderList/专票标签.png",width:40.w ,height: 15.h,),
                                        if(fleetOrderList[index]['category']==1)
                                          Image.asset("lib/Images/OrderList/分配单标签.png",width:50.w ,height: 16.h,),
                                      ],
                                    ),
                                    if(fleetOrderList[index]['riskStatus']==1)
                                      Image.asset("lib/Images/OrderList/异常运单.png",width:70.w ,height:20.h,),
                                  ],


                                ),
                                // SizedBox(height: 8.h,),


                                Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    SizedBox(width: 10.w,),
                                    Column(
                                      children: [

                                        Image.asset("lib/Images/OrderList/装货点icon.png",width:20.w ,height:20.h,),
                                        Image.asset("lib/Images/OrderList/垂直虚线.png",width:13.w ,height:20.h,),
                                        if(fleetOrderList[index]['goodsInfo']['loadPlaceInfo'].length==2)
                                          Column(
                                            crossAxisAlignment: CrossAxisAlignment.start,
                                            children: [
                                              Image.asset("lib/Images/OrderList/装货点icon.png",width:20.w ,height:20.h,),
                                              Image.asset("lib/Images/OrderList/垂直虚线.png",width:18.w ,height:20.h,),
                                            ],
                                          ),
                                        if(fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'].length==2)
                                          Column(
                                            children: [
                                              Image.asset("lib/Images/OrderList/卸货点icon.png",width:20.w ,height:20.h,),
                                              Image.asset("lib/Images/OrderList/垂直虚线.png",width:18.w ,height:20.h,),
                                            ],
                                          ),
                                        Image.asset("lib/Images/OrderList/卸货点icon.png",width:20.w ,height:20.h,),
                                      ],
                                    ),
                                    SizedBox(width: 4.w,),

                                    Column(
                                      crossAxisAlignment: CrossAxisAlignment.start,
                                      children: [
                                        SizedBox(height: 8.h,),
                                        Row(
                                          children: [
                                            Container(
                                              constraints: BoxConstraints(
                                                maxWidth:170.w, // 限制文本最大宽度
                                              ),
                                              child:
                                              Text(fleetOrderList[index]['goodsInfo']['loadPlaceInfo'][0]['city']+" "+fleetOrderList[index]['goodsInfo']['loadPlaceInfo'][0]['county'],style: TextStyle(color: Colors.black,overflow: TextOverflow.ellipsis,fontSize: 14.sp,fontWeight: FontWeight.w600),),
                                            ),
                                            SizedBox(width: 4.w,),
                                            Container(
                                              constraints: BoxConstraints(
                                                maxWidth:screenSize.width-220.w, // 限制文本最大宽度
                                              ),
                                              child: Text(fleetOrderList[index]['goodsInfo']['loadDay']+fleetOrderList[index]['goodsInfo']['loadTime']+"点装货",overflow: TextOverflow.ellipsis,style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                                            ),

                                          ],
                                        ),
                                        Container(
                                          constraints: BoxConstraints(
                                            maxWidth:screenSize.width-70.w, // 限制文本最大宽度
                                          ),
                                          child: Text(fleetOrderList[index]['goodsInfo']['loadPlaceInfo'][0]['address'],style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),   overflow: TextOverflow.ellipsis,),

                                        ),

                                        if(fleetOrderList[index]['goodsInfo']['loadPlaceInfo'].length==2)
                                          Column(
                                            crossAxisAlignment: CrossAxisAlignment.start,
                                            children: [
                                              SizedBox(height: 8.h,),
                                              Container(
                                                constraints: BoxConstraints(
                                                  maxWidth:170.w, // 限制文本最大宽度
                                                ),
                                                child:Text(fleetOrderList[index]['goodsInfo']['loadPlaceInfo'][1]['city']+" "+fleetOrderList[index]['goodsInfo']['loadPlaceInfo'][1]['county'],style: TextStyle(color: Colors.black,fontSize: 14.sp,fontWeight: FontWeight.w600),overflow: TextOverflow.ellipsis,),

                                              ),
                                              Container(
                                                constraints: BoxConstraints(
                                                  maxWidth:screenSize.width-70.w, // 限制文本最大宽度
                                                ),
                                                child: Text(fleetOrderList[index]['goodsInfo']['loadPlaceInfo'][1]['address'],style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),overflow: TextOverflow.ellipsis,),

                                              ),
                                            ],
                                          ),
                                        SizedBox(height:8.h,),
                                        if(fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'].length==2)
                                          Column(
                                            crossAxisAlignment: CrossAxisAlignment.start,
                                            children: [
                                              Container(
                                                constraints: BoxConstraints(
                                                  maxWidth:170.w, // 限制文本最大宽度
                                                ),
                                                child: Text(fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'][0]['city']+" "+fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'][0]['county'],style: TextStyle(color: Colors.black,fontSize: 14.sp,fontWeight: FontWeight.w600),overflow: TextOverflow.ellipsis,),

                                              ),
                                              Container(
                                                constraints: BoxConstraints(
                                                  maxWidth:screenSize.width-70.w, // 限制文本最大宽度
                                                ),
                                                child: Text(fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'][0]['address'],style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),overflow: TextOverflow.ellipsis,),
                                              ),

                                              SizedBox(height:8.h,),
                                            ],
                                          ),
                                        Row(
                                          children:[
                                            fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'].length==2?
                                            Container(
                                                constraints: BoxConstraints(
                                                  maxWidth:170.w, // 限制文本最大宽度
                                                ),
                                                child: Text(fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'][1]['city']+" "+fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'][1]['county'],style: TextStyle(color: Colors.black,fontSize: 14.sp,fontWeight: FontWeight.w600),overflow: TextOverflow.ellipsis,)
                                            )
                                                :
                                            Container(
                                              constraints: BoxConstraints(
                                                maxWidth:170.w, // 限制文本最大宽度
                                              ),
                                              child:  Text(fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'][0]['city']+" "+fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'][0]['county'],style: TextStyle(color: Colors.black,fontSize: 14.sp,fontWeight: FontWeight.w600),overflow: TextOverflow.ellipsis,),
                                            ),

                                            SizedBox(width: 4.w,),
                                            if (fleetOrderList[index]['goodsInfo']['unloadDay'] != null)
                                              Container(
                                                constraints: BoxConstraints(
                                                  maxWidth:screenSize.width-220.w, // 限制文本最大宽度
                                                ),
                                                child: Text(fleetOrderList[index]['goodsInfo']['unloadDay']+" "+fleetOrderList[index]['goodsInfo']['unloadTime']+"点卸货",overflow: TextOverflow.ellipsis,style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),

                                              ) ,                                  ],
                                        ),
                                        fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'].length==2?
                                        Container(
                                            constraints: BoxConstraints(
                                              maxWidth:screenSize.width-70.w, // 限制文本最大宽度
                                            ),
                                            child:Text(fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'][1]['address'],style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),overflow: TextOverflow.ellipsis,)
                                        )
                                            :
                                        Container(
                                          constraints: BoxConstraints(
                                            maxWidth:screenSize.width-70.w, // 限制文本最大宽度
                                          ),
                                          child:  Text(fleetOrderList[index]['goodsInfo']['unloadPlaceInfo'][0]['address'],style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),overflow: TextOverflow.ellipsis,),
                                        ),

                                      ],
                                    ),

                                  ],
                                ),
                                SizedBox(height: 4.h,),
                                Row(
                                  children: [
                                    SizedBox(width:10.w,),
                                    Text( fleetOrderList[index]['goodsInfo']['cargoInfo'][0]['cargoName'].toString()+","+fleetOrderList[index]['goodsInfo']['cargoInfo'][0]['packageType'].toString(),style: TextStyle(color:MyColors.textColor,fontSize: 13.sp ),),
                                    if(fleetOrderList[index]['goodsInfo']['cargoInfo'][0]['cargoWeight']!=null)
                                      Text( ","+fleetOrderList[index]['goodsInfo']['cargoInfo'][0]['cargoWeight'].toString()+"吨",style: TextStyle(color:MyColors.textColor,fontSize: 13.sp ),) ,
                                    if(fleetOrderList[index]['goodsInfo']['cargoInfo'][0]['cargoVolume']!=null)
                                      Text( ","+fleetOrderList[index]['goodsInfo']['cargoInfo'][0]['cargoVolume'].toString()+"方",style: TextStyle(color:MyColors.textColor,fontSize: 13.sp ),)
                                  ],
                                ),
                                SizedBox(height: 8.h,),
                                Container(
                                  margin: EdgeInsets.only(left: 20.w,right: 20.w),
                                  height: 1.h,
                                  color: Color.fromRGBO(245, 243, 243, 1),
                                ),
                                SizedBox(height: 8.h,),
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Row(
                                      children: [
                                        SizedBox(width: 8.w,),
                                        Container(
                                          decoration: BoxDecoration(
                                              color: Colors.white,
                                              borderRadius: BorderRadius.all(Radius.circular(10))),
                                          child: ClipOval(
                                            child: fleetOrderList[index]['shipperInfo']['avatarPath']!=""&&fleetOrderList[index]['shipperInfo']['avatarPath']!=null?Image.network(
                                              MyServiceUrl.imgHeader + fleetOrderList[index]['shipperInfo']['avatarPath'],
                                              width: 36.w,
                                              height: 36.h,
                                              fit: BoxFit.cover,
                                            ):Image.asset("lib/Images/login/默认头像.jpeg",width: 36.w,height: 36.h, fit: BoxFit.cover,),
                                          ),
                                        ),
                                        Column(
                                          crossAxisAlignment: CrossAxisAlignment.start,
                                          children: [
                                            Row(
                                              crossAxisAlignment: CrossAxisAlignment.start,
                                              children: [
                                                SizedBox(width: 8.w,),
                                                Text(fleetOrderList[index]['shipperInfo']['realName'].toString(),style: TextStyle(color: Colors.black,fontSize: 13.sp ),),
                                              ],
                                            ),
                                            if(fleetOrderList[index]['haulierInfo']!=null)
                                              Row(
                                                children: [
                                                  SizedBox(width: 4.w,),
                                                  Text(fleetOrderList[index]['haulierInfo']['name'].toString(),style: TextStyle(color:MyColors.textColor,fontSize: 12.sp ),)
                                                ],
                                              ),


                                          ],
                                        ),

                                      ],
                                    ),
                                    // Row(
                                    //   children: [
                                    //     GestureDetector(
                                    //       child: Image.asset("lib/Images/OrderList/IMicon.png",width: 24.w,height: 24.h,),
                                    //       onTap: (){
                                    //
                                    //
                                    //       },
                                    //     ),
                                    //     SizedBox(width: 8.w,),
                                    //     GestureDetector(
                                    //       child: Image.asset("lib/Images/OrderList/电话联系icon.png",width: 24.w,height: 24.h,),
                                    //       onTap: (){
                                    //         _makePhoneCall(dataList[index]['drvPhoneNum']);
                                    //       },
                                    //     ),
                                    //   ],
                                    // )


                                  ],
                                ),
                                SizedBox(height:8.h,),
                                Container(
                                  margin: EdgeInsets.only(left: 20.w,right: 20.w),
                                  height: 1.h,
                                  color: Color.fromRGBO(245, 243, 243, 1),
                                ),
                                SizedBox(height:8.h,),
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    fleetOrderList[index]['insuranceStatus']==1?
                                    Image.asset("lib/Images/OrderList/保险icon.png",width: 50.w,height: 20.h,):SizedBox(),
                                    Row(
                                      children: [

                                        RichText(
                                          text:TextSpan(children: [
                                            if(fleetOrderList[index]['depositType']!=-1)
                                              TextSpan(
                                                  text: messages["订金"],
                                                  style: TextStyle(fontSize: 11.sp, color: Colors.black)),
                                            if(fleetOrderList[index]['depositType']!=-1)
                                              TextSpan(
                                                  text: '¥'+(fleetOrderList[index]['deposit']).toString(),
                                                  style: TextStyle(fontSize: 11.sp, color: Color.fromRGBO(231, 112, 27, 0.85))),
                                            if(fleetOrderList[index]['depositType']!=-1)
                                              TextSpan(
                                                  text: fleetOrderList[index]['depositStatus']==0?'(待支付)':fleetOrderList[index]['depositStatus']==2?"(已退回)":fleetOrderList[index]['depositStatus']==1?"(平台监管中)":"(已支付到货主)",
                                                  style: TextStyle(fontSize: 11.sp, color: Colors.black)),
                                            TextSpan(
                                                text: messages["运费"],
                                                style: TextStyle(fontSize: 11.sp, color: Colors.black)),
                                            if(fleetOrderList[index]['freight']!="0.000")
                                              TextSpan(
                                                  text: '¥'+fleetOrderList[index]['freight'],
                                                  style: TextStyle(fontSize: 11.sp, color: Color.fromRGBO(231, 112, 27, 0.85))),
                                            if(fleetOrderList[index]['price']!="0.000"&&fleetOrderList[index]['freight']=="0.000")
                                              TextSpan(
                                                  text: '¥'+fleetOrderList[index]['price'],
                                                  style: TextStyle(fontSize: 11.sp, color: Color.fromRGBO(231, 112, 27, 0.85))),
                                            TextSpan(
                                                text: fleetOrderList[index]['freightStatus']==-1?'(线下支付)':fleetOrderList[index]['freightStatus']==0?'(待支付)':fleetOrderList[index]['freightStatus']==1?"(平台监管中)":fleetOrderList[index]['freightStatus']==2?"(支付到司机)":"(已退回到货主)",
                                                style: TextStyle(fontSize: 11.sp, color: Colors.black)),
                                          ],
                                          ),
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                                SizedBox(height: 8.h,),


                                // Row(
                                //   mainAxisAlignment: MainAxisAlignment.end,
                                //   children: [
                                //
                                //     if(fleetOrderList[index]['contractStatus']==0&&fleetOrderList[index]['contractMode']=="DRIVER"&&fleetOrderList[index]['cancelStatus']!=1)
                                //       GestureDetector(
                                //         child:  Container(
                                //             width: 75.w,
                                //             height: 25.h,
                                //             decoration: BoxDecoration(
                                //               color: Colors.white,
                                //               borderRadius: BorderRadius.circular(30.0),
                                //               border: Border.all(
                                //                 color: MyColors.themeColor,
                                //                 width: 1.0,
                                //               ),
                                //             ),
                                //             child: Center(child: Text("查看协议",style: TextStyle(fontSize: 13.sp,color: MyColors.themeColor,fontWeight: FontWeight.w600),),)
                                //         ),
                                //         onTap: ()  {
                                //           Navigator.push( context, FadeRoute(page:UnconfirmedTransportationAgreement(wayBillId: fleetOrderList[index]['id'], Type: 1,
                                //           )));
                                //         },
                                //       ),
                                //     if((dataList[index]['contractStatus']==0||dataList[index]['contractStatus']==2)&&dataList[index]['contractMode']=="SHIPPER"&&dataList[index]['cancelStatus']!=1)
                                //       GestureDetector(
                                //         child:  Container(
                                //             width: 75.w,
                                //             height: 25.h,
                                //             decoration: BoxDecoration(
                                //               color: Colors.white,
                                //               borderRadius: BorderRadius.circular(30.0),
                                //               border: Border.all(
                                //                 color: MyColors.themeColor,
                                //                 width: 1.0,
                                //               ),
                                //             ),
                                //             child: Center(child: Text("确认协议",style: TextStyle(fontSize: 13.sp,color: MyColors.themeColor,fontWeight: FontWeight.w600),),)
                                //         ),
                                //         onTap: ()  {
                                //           Navigator.push( context, FadeRoute(page:UnconfirmedTransportationAgreement(wayBillId: dataList[index]['id'], Type: 1,
                                //           )));
                                //         },
                                //       ),
                                //
                                //     if(dataList[index]['deliveryStatus']==0&&dataList[index]['driverStatus']==0&&dataList[index]['contractStatus']==1&&dataList[index]['cancelStatus']!=1)
                                //       Row(
                                //         children: [
                                //           SizedBox(width: 8.w,),
                                //           GestureDetector(
                                //             child:  Container(
                                //                 width: 85.w,
                                //                 height: 25.h,
                                //                 decoration: BoxDecoration(
                                //                   color: Colors.white,
                                //                   borderRadius: BorderRadius.circular(30.0),
                                //                   border: Border.all(
                                //                     color: MyColors.themeColor,
                                //                     width: 1.0,
                                //                   ),
                                //                 ),
                                //                 child: Center(child: Text("确认已装货",style: TextStyle(fontSize: 13.sp,color: MyColors.themeColor,fontWeight: FontWeight.w600),),)
                                //             ),
                                //             onTap: ()  {
                                //               showDialog(
                                //                   context: context,
                                //                   builder: (BuildContext context) {
                                //                     return upLpadCarphotoAlert(dataMap: dataList[index], photoType: 1,);
                                //
                                //                   }
                                //               );
                                //             },
                                //           ),
                                //         ],
                                //       ),
                                //     if(dataList[index]['deliveryStatus']==0&&dataList[index]['driverStatus']==1&&dataList[index]['cancelStatus']!=1)
                                //       Row(
                                //         children: [
                                //           SizedBox(width: 8.w,),
                                //           GestureDetector(
                                //             child:  Container(
                                //                 width: 85.w,
                                //                 height: 25.h,
                                //                 decoration: BoxDecoration(
                                //                   color: Colors.white,
                                //                   borderRadius: BorderRadius.circular(30.0),
                                //                   border: Border.all(
                                //                     color: MyColors.themeColor,
                                //                     width: 1.0,
                                //                   ),
                                //                 ),
                                //                 child: Center(child: Text("确认已卸货",style: TextStyle(fontSize: 13.sp,color: MyColors.themeColor,fontWeight: FontWeight.w600),),)
                                //             ),
                                //             onTap: ()  {
                                //               showDialog(
                                //                   context: context,
                                //                   builder: (BuildContext context) {
                                //                     return upLpadCarphotoAlert(dataMap: dataList[index], photoType: 2,);
                                //
                                //                   }
                                //               );
                                //             },
                                //           ),
                                //         ],
                                //       ),
                                //     if(dataList[index]['driverStatus']==2&&dataList[index]['deliveryStatus']==0&&dataList[index]['cancelStatus']!=1)
                                //       Row(
                                //         children: [
                                //           SizedBox(width: 8.w,),
                                //           GestureDetector(
                                //             child:  Container(
                                //                 width: 75.w,
                                //                 height: 25.h,
                                //                 decoration: BoxDecoration(
                                //                   color: MyColors.themeColor,
                                //                   borderRadius: BorderRadius.circular(30.0),
                                //                   border: Border.all(
                                //                     color: MyColors.themeColor,
                                //                     width: 1.0,
                                //                   ),
                                //                 ),
                                //                 child: Center(child: Text(dataList[index]['receiptStatus']==0?'上传回单':"查看回单",style: TextStyle(fontSize: 13.sp,color: Colors.white,fontWeight: FontWeight.w600),),)
                                //             ),
                                //             onTap: ()  {
                                //               if(dataList[index]['receiptStatus']==0){
                                //                 Navigator.push( context, FadeRoute(page:UploadPhotoPage(dataMap: dataList[index], uploadType: 3,)));
                                //
                                //               }else{
                                //                 Navigator.push( context, FadeRoute(page:PictureManagement(type: 1,dataMap: dataList[index])));
                                //               }
                                //             },
                                //           ),
                                //         ],
                                //       ),
                                //     if(dataList[index]['driverEvaluateStatus']==0&&(dataList[index]['driverStatus']==2||dataList[index]['deliveryStatus']==1&&dataList[index]['cancelStatus']!=1))
                                //       Row(
                                //         children: [
                                //           SizedBox(width: 8.w,),
                                //           GestureDetector(
                                //             child:  Container(
                                //                 width: 75.w,
                                //                 height: 25.h,
                                //                 decoration: BoxDecoration(
                                //                   color: MyColors.themeColor,
                                //                   borderRadius: BorderRadius.circular(30.0),
                                //                   border: Border.all(
                                //                     color: MyColors.themeColor,
                                //                     width: 1.0,
                                //                   ),
                                //                 ),
                                //                 child: Center(child: Text("评价货主",style: TextStyle(fontSize: 13.sp,color: Colors.white,fontWeight: FontWeight.w600),),)
                                //             ),
                                //             onTap: ()  {
                                //               Navigator.push( context, FadeRoute(page:EvaluationPage(dataMap: dataList[index],)));
                                //             },
                                //           ),
                                //
                                //         ],
                                //       ),
                                //
                                //   ],
                                // ),

                              ],
                            ),
                          ),

                          onTap: () async {
                            // Navigator.push( context, FadeRoute(page:WaybillDetails(billId: fleetOrderList[index]['id'], type: 1,)));


                          },
                        );


                      },
                      separatorBuilder: (context, index) { //自定义分割线
                        return   Container(
                          height: 8.h,
                        );
                      },


                    ),
                  )):isCheck==0&&carNumberList.length==0?
              Container(
                child: Center(
                  child: Column(
                    children: [
                      SizedBox(height: 40.h,),
                      Image.asset("lib/Images/PersonCenter/我的车队空白页状态.png",height: 212.h,width: 212.w,),
                      Text("您还没有添加过车辆哦～",style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
                    ],
                  ),
                ),

                  ):
                  SizedBox(width: 0,),


      ],
    ),
    ),
      if(widget.captainId!=driverId)
        Container(
          height:  80.h,
          color: Colors.white,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Container(
                  height: 40.h ,
                  margin: EdgeInsets.only(left: 30.w,right: 30.w),
                  decoration: BoxDecoration(
                      color:Color.fromRGBO(231, 112, 27, 0.85),
                      borderRadius: BorderRadius.all(Radius.circular(30))),
                  width: double.infinity,
                  child: TextButton(
                    child: Text("退出车队",style: TextStyle(color: Colors.white,fontSize: 14.sp,fontWeight: FontWeight.w600),),
                    onPressed: ()async{
                      showDialog(
                        barrierDismissible: false,
                        context: context,
                        builder: (BuildContext context) {
                          return BrnDialog(

                            titleText: "确定要退出车队吗？",
                            actionsWidget: [
                              TextButton(
                                onPressed: () {
                                  Navigator.pop(context);
                                },
                                child: Text("取消",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                              ),
                              TextButton(
                                onPressed: () {
                                  NoLoadinggetApiManager.getData(
                                    context,
                                    "api/auth/driver/fleet/user/unbind",
                                    {'driverId':driverId,},
                                        (responseData)  {
                                      setState(() {
                                        Navigator.pop(context);
                                      Navigator.pop(context,"success");

                                      });

                                    },
                                  );
                                },
                                child: Text("确定",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                              ),
                            ],
                          );
                        },
                      );

                    },
                  )
              ),
            ],
          ),
        ),
    if(widget.captainId==driverId)
      Container(
        height: isCheck==2?0: 80.h,
        color: Colors.white,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
                height: 40.h ,
                margin: EdgeInsets.only(left: 30.w,right: 30.w),
                decoration: BoxDecoration(
                    color:Color.fromRGBO(231, 112, 27, 0.85),
                    borderRadius: BorderRadius.all(Radius.circular(30))),

                width: double.infinity,


                child: TextButton(
                  child: Text(isCheck==0? messages["添加车辆"]:messages['邀请队员'],style: TextStyle(color: Colors.white,fontSize: 14.sp,fontWeight: FontWeight.w600),),

                  onPressed: ()async{
                    if(isCheck==0){
                     final result=await Navigator.push( context, FadeRoute(page:FleetInformationView(fleetMap: fleetData, id: '',)));
                     if(result==null){
                       getFleetVehicles();
                     }

                    }else{
                      final result=await Navigator.push( context, FadeRoute(page:InvitingDrivers(fleetMap:fleetData,)));
                      if(result==null){
                        getFleetDriversAction();
                      }
                    }
                  },
                )
            ),
          ],
        ),
      ),
        ],
      ),
    );
  }
}
